Repository navigation
fix(aio): avoid retrying successfully submitted batches - #2417
Open
Alex Castillo González (pcbeingused333) wants to merge 1 commit into
Open
Alex Castillo González (pcbeingused333) wants to merge 1 commit into
Alex Castillo González (pcbeingused333) wants to merge 1 commit into
Conversation
Alex Castillo González (pcbeingused333)
requested review from
a team and
Matthew Seal (MSeal)
as code owners
November 8, 2026 21:01
|
Please sign the Contributor License Agreement here before this PR can be approved. |
Author
|
Gentle ping: this is ready for review whenever someone has a moment. Happy to rebase or adjust anything if needed. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A flush can submit one topic/partition batch and then fail on a later one. The exception handler in
flush_bufferputs every batch back in the buffer, so the next flush produces the earlier messages again, even if they were already delivered or their delivery callbacks are still pending.One way to hit it:
produce_batchraisesTypeErrorwhen a message value is not bytes or str. With a valid message for partition 0 andvalue=123for partition 1, each flush fails on partition 1 and resubmits partition 0. The automatic buffer timeout flush can repeat this without the application calling anything.This change removes the successfully submitted prefix from the retry list on failure. The failed batch and the unattempted batches stay buffered, so the existing retry and future failure behavior does not change.
Checklist
References
JIRA: none, no existing issue. Added a changelog entry.
Test & Review
tests/test_producer_batch_processor.py: full and topic-selective flushes, with delivered and pending callbacks. It checks the preserved futures and the calls made by the next flush. No broker needed.tests/test_producer_batch_processor.pyandtests/test_kafka_batch_executor.py: 25 passed, 4 subtests passed.Producerand no broker, the example above over three flushes submits the partition 0 message 3 times on master and once with the change.AI assistance: this change and its tests were prepared with Codex and reviewed with Claude.